package utils
{
	import fl.motion.BezierSegment;
	
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.utils.setTimeout;

	public class DrawBez
	{
		private var _n:Number=0;
		private var _to;
		private var _clip:Sprite;
		private var _bs:BezierSegment;
		public function DrawBez(clp:Sprite,points:Array,time:int)
		{
			_clip=clp;
			_clip.graphics.lineStyle(10,1,0xFF0000);
			_bs=new BezierSegment(points[0],points[1],points[2],points[3]);
			drawLine();
		}
		private function drawLine()
		{	
			trace("draw",_n);
			var p:Point = _bs.getValue(_n);
			_clip.graphics.lineTo(p.x,p.y);
			_n+=.01;
			if(_n>1)
			{
				_n=1;
			}
			else
			{
				_to=setTimeout(drawLine,1);
			}			
		}		
	}
}